package com.news.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.news.dao.UserDao;
import org.news.dao.impl.UserDaoImpl;

@WebServlet(name="user",urlPatterns="/userServlet")
public class UserServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter out = resp.getWriter();
		String uname = req.getParameter("uname");
		UserDao userDao  =new UserDaoImpl();
		boolean flag = userDao.checkName(uname);
		if(flag ==true){
			out.print("true");
		}else{
			out.print("false");
		}
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
	
}
